<?php
    header("Content-type:text/html; charset=utf-8");
    //创建连接
    $link=mysqli_connect("localhost","root","","my_database");
    //数据库连接错误
    if (!$link) {
        exit("数据库连接错误".mysqli_connect_error());
    
    } 
    //字符集设置错误1
    if (!mysqli_set_charset($link,"utf8")) {
        exit("字符集设置错误".mysqli_connect_error($link));
        
    } 
    //测试成功
    //echo"连接数据库成功!";
?>